package com.jintu.portal.repository.mysql.dao;

import com.jintu.portal.pojo.entity.mysql.RuleChain;
import com.jintu.portal.pojo.exception.DaoException;
import com.jintu.portal.repository.mysql.mapper.RuleChainMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author very
 */
@Slf4j
@Repository("ruleChainDao")
public class RuleChainDao {

    @Resource
    private RuleChainMapper ruleChainMapper;

    public RuleChain queryMyselfRuleChainByCode(String ruleChainCode, Integer userId) throws DaoException {
        try {
            return ruleChainMapper.queryMyselfRuleChainByCode(ruleChainCode, userId);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }

    public RuleChain queryOthersRuleChainByCode(String ruleChainCode, String username) throws DaoException {
        try {
            return ruleChainMapper.queryOthersRuleChainByCode(ruleChainCode, username);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }

    public List<String> queryDependencyScoreCards(String ruleChainCode)throws DaoException {
        try {
            return ruleChainMapper.queryDependencyScoreCards(ruleChainCode);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }
}
